﻿using System;
using System.Linq;
using System.Collections.Generic;
using Microsoft.Practices.ServiceLocation;
using NCommon.Data;

namespace MyPetShop.Domain
{
	/// <summary>
	/// Description of Category.
	/// </summary>
	public class Category
	{
		public virtual int CateoryId {get;set;}
		public virtual string Name {get;set;}
		public virtual bool IsDelete {get;protected set;}
		
		public Category()
		{
			
		}
		
		public virtual void Delete()
		{
			var repository = ServiceLocator.Current.GetInstance<IRepository<Product>>();
			IList<Product> products = repository.Where(s=>s.Category == this).ToList();
			
			foreach(var product in products)
			{
				product.Delete();
			}
		}
	}
}
